//
//  XDHappyFamilyViewController.m
//  XDEducation
//
//  Created by apple on 2017/4/7.
//  Copyright © 2017年 apple. All rights reserved.
//

#import "XDHappyFamilyViewController.h"
#import "XDConstantHeaderFile.h"
#import "XDHappinessCell.h"
#define kCell @"cell"
@interface XDHappyFamilyViewController ()<UICollectionViewDelegate,UICollectionViewDataSource>
@property (nonatomic,strong) UIScrollView *allScrollview;
@property (nonatomic,strong) UICollectionView *collectionView;
@end

@implementation XDHappyFamilyViewController

- (void)viewDidLoad {
    [super viewDidLoad];
  
    [self  setUpSuperView];
}

- (void)setUpSuperView{
    
    self.allScrollview = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0,kScreenWidth , kScreenHeight)];
    self.allScrollview.backgroundColor = [UIColor redColor];
    [self.view addSubview:self.allScrollview];
    
    self.allScrollview.contentSize = CGSizeMake(kScreenWidth, kScreenHeight + 100);
//    34
//    35     // 隐藏水平滚动条
//    36     scrollView.showsHorizontalScrollIndicator = NO;
//    37     scrollView.showsVerticalScrollIndicator = NO;
    
    UICollectionViewFlowLayout *layout = [UICollectionViewFlowLayout  new];
    layout.itemSize = CGSizeMake(kScreenWidth/2,kScreenHeight *150/1334);
    
    layout.scrollDirection = UICollectionViewScrollDirectionVertical;
    self.collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight *645/1334) collectionViewLayout:layout];

    self.collectionView.dataSource = self;
    self.collectionView.delegate = self;
    [self.collectionView registerClass:[XDHappinessCell class] forCellWithReuseIdentifier:kCell];
    [self.allScrollview addSubview:self.collectionView];
    self.collectionView.backgroundColor = [UIColor greenColor];

    
    
    
    
    
}
#pragma mark -----collectionView delegate方法
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
    return 1;
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    
    return 20;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    
    XDHappinessCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:kCell forIndexPath:indexPath];
    
    
//    NSDictionary *dic = self.dataArr[indexPath.row];
//    [cell setClickImage:^{
//        NSDictionary *dic = self.dataArr[indexPath.row];
//        NSString *userId = [dic valueForKey:@"userId"];
//        NearByViewController *nearByVC = [[NearByViewController alloc] init];
//        nearByVC.userId = userId;
//        [self.navigationController pushViewController:nearByVC animated:YES];
//        
//    }];
    //    NSString *path;
    //    if ([[dic valueForKey:@"iconUrl"] hasPrefix:@"http:"]) {
    //        path = [dic valueForKey:@"iconUrl"];
    //    }else{
    //        path = [NSString stringWithFormat:smil,[dic valueForKey:@"iconUrl"]];
    //    }
//    [cell.iconImageView sd_setImageWithURL:[NSURL URLWithString:[dic valueForKey:@"iconUrl"]] placeholderImage:[UIImage imageNamed:@"seat"]];
    return cell;
}


@end
